﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Xunit;

namespace dogd.Tests
{

	public class FilterByFacts
	{
		public class TheToStringMethod
		{
			[Fact]
			public void WillIncludeNameAtNameForNameOnlyFilter()
			{
				var filter = new FilterBy("Size");

				Assert.Equal("Size = @Size", filter.ToString());
			}

			[Fact]
			public void WillIncludeNameAndAtVariableForNameVariableFilter()
			{
				var filter = new FilterBy("Name", "FullName");

				Assert.Equal("Name = @FullName", filter.ToString());
			}

			[Fact]
			public void WillIncludeNotEqualForNameOperatorVariableFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("Name", FilterOperator.NotEqual, "Bob");

				Assert.Equal("Name <> \'Bob\'", filter.ToString());
			}

			[Fact]
			public void WillIncludeLessThanForNameOperatorVariableFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("Name", FilterOperator.LessThan, "Bob");

				Assert.Equal("Name < \'Bob\'", filter.ToString());
			}
			[Fact]
			public void WillIncludeLessThanOrEqualForNameOperatorVariableFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("Name", FilterOperator.LessThanOrEqual, "Bob");

				Assert.Equal("Name <= \'Bob\'", filter.ToString());
			}

			[Fact]
			public void WillIncludeGreaterThanForNameOperatorVariableFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("Name", FilterOperator.GreaterThan, "Bob");

				Assert.Equal("Name > \'Bob\'", filter.ToString());
			}

			[Fact]
			public void WillIncludeGreaterThanOrEqualForNameOperatorVariableFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("Name", FilterOperator.GreaterThanOrEqual, "Bob");

				Assert.Equal("Name >= \'Bob\'", filter.ToString());
			}

			[Fact]
			public void WillIncludeValueForPrimaryKeyFilter()
			{
				// filer by variable name / literal name
				var filter = new FilterBy("ID", FilterOperator.Equal, new Key () { Value = 101 });

				Assert.Equal("ID = 101", filter.ToString());
			}

		}
	}
}
